<template>
  <div class="main" :style="'background-image:url(/img/login/background.jpg)'" :hidden="loadAwaitHidden">
    <img style="width: 100%; position: fixed; top: 0;" src="/img/login/top(logo).png">
    <div class="form">
      <a-row class="login-layout-row" style="min-width: 50%;">
        <a-col class="form-right">
          <div v-if="!isSet" class="title">虎门外语学校协同办公系统</div>
          <div v-if="!isSet" class="des-en">User Login</div>
          <div v-else class="des-en">修改密码</div>
          <transition name="page-transition" mode="out-in" appear>
            <route-view :keep-alive="false" />
          </transition>
        </a-col>
      </a-row>
    </div>
  </div>
</template>

<script>
import RouteView from './route-view'

export default {
  name: 'LoginLayout',
  components: {
    RouteView
  },

  data () {
    return {
      isSet: false,
      loadAwaitHidden: false
    }
  },

  watch: {
    $route: {
      handler (t, f) {
        const that = this
        console.log('layout watch route', t.name, f && f.name)
        if (!f || !f.name || t.name === 'system-Account') { // 进入
          this.isSet = false
          this.loadAwaitHidden = true
          this.$nextTick(_ => {
            that.loadAwaitHidden = false
          })
        }
      },
      immediate: true
    }
  }

}
</script>

<style lang="less" scoped>

.page-transition-enter-active,
.page-transition-leave-active {
  transition: opacity .8s;
}

.page-transition-enter,
.page-transition-leave-to {
  opacity: 0;
}

.page-transition-enter-to,
.page-transition-leave {
  opacity: 1;
}

/* login */
.main {
  background-position: center;
  background-size: cover;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;

  .form {
    position: absolute;
    top: 55%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 10px;
    width: 56.04166666666667%;
    min-width: 800px;
    min-height: 47.03703703703704%;
    background-image: url('/img/login/login-form-width-comput.png');
    background-size: 100%;
    background-repeat: no-repeat;
    .Flex;
    .Flex-justify-end;

    .logo {
      img {
        width: 40%;
        height: auto;
        margin-bottom: 30px;
      }
    }
    .form-right{
      border-radius: 20px;
      padding: 3.90625vw 5.46875vw;
      // padding: 30px 70px 24px 70px;
      // padding-left: 0;
      // margin-left: 59.66542750929368%;

      img{
        width: 70%;
        margin-left: 15%;
        margin-bottom: 24px;
      }
      .title{
        font-size: 20px;
        color: #1f90f1;
        text-align: center;
        font-weight: 600;
      }
      .des-en{
        color:#9b9b9b;
        text-align: center;
        margin-bottom: 15px;
      }
      /* /deep/ .ant-form-item{
        /deep/ input{
          border-style: solid;
          border-color: #ccc;
          border-width: 0 0 1px 0 !important;
          border-radius: 0;
          background: #fff !important;
          &:focus{
            background: #fff !important;
            box-shadow: none !important;
          }
        }
      }
      */
      /deep/ .ant-form-item{
        margin-bottom:10px;
      }

      /deep/ .login-btn {
        border: none !important;
        color:#fff !important;
        font-size: 14px;
        padding: 18px 20px !important;
        margin-top: 16.66% !important;
        margin-left: 0 !important;
        border: none !important;
        // font-size: 18px;
        border-radius: 6px !important;
        width: 70% !important;
        background: #0066d7 !important;
      }
    }
  }
}

  /deep/ .login-input,
  input:-internal-autofill-selected {
    background-color: transparent !important;
    border: 1px solid #3583d8;
  }

  /deep/ .login-form-item {
    height: 60px !important;
    margin-bottom: 0 !important;
  }

  /deep/ .login-form-item.password,
  /deep/ .login-form-item.username {
    position: relative;

    input {
      padding-left: 50px;
    }

    &::before {
      content: "";
      padding: 0 14px;
      position: absolute;
      z-index: 999999;
      top: 20px;
      left: 2px;
      transform: translateY(-50%);
      border-right: 1px solid #424340;
      width: 12px;
      height: 16px;
      padding-left: 16px;
      padding-right: 16px;
      background-image: url('/img/login/icon-username.png');
      background-size: 12px;
      background-position: center;
      background-repeat: no-repeat;
    }
  }

  /deep/ .login-form-item.password {
    &::before {
      background-image: url('/img/login/icon-password.png') !important;
    }
  }

  /deep/ .form /deep/ .ant-row.ant-form-item.ant-form-item-with-help .ant-form-item-control-wrapper .ant-form-item-control.has-error {
    /deep/ .ant-form-explain,
    /deep/ .ant-form-split {
      position: absolute !important;
    }
  }

  /deep/ .form .form-right .ant-form-item {
    margin-bottom: 0 !important;
  }

</style>
